package com.njupt.swg.threadstudyjimin.item05.singleton;

import com.njupt.swg.threadstudyjimin.annotation.ThreadSafe;

/**
 * 饿汉模式-staic块实现
 */
@ThreadSafe
public class SingletonExample4 {
    private SingletonExample4(){}

    private static SingletonExample4 instance = null;

    static {
        instance = new SingletonExample4();
    }

    public static SingletonExample4 getInstance(){
        return instance;
    }

    public static void main(String[] args) {
        System.out.println(getInstance());
        System.out.println(getInstance());
    }
}
